#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int maximumUniqueSubarray(vector<int>& nums) {
        int hash[10001]{};
        int l = 0, r = 0;
        int n = nums.size();
        int ret = 0;
        int cur = 0;
        while (r < n)
        {
            hash[nums[r]]++;
            cur += nums[r];
            while (hash[nums[r]] > 1)
            {
                hash[nums[l]]--;
                cur -= nums[l];
                l++;
            }
            ret = max(ret, cur);
            r++;
        }
        return ret;
    }
};